from typing import Dict, Any
import pandas as pd
from .strategy_base import StrategyBase

class MovingAverageStrategy(StrategyBase):
    def __init__(self, parameters: Dict[str, Any] = None):
        default_params = {
            'short_window': 20,
            'long_window': 50
        }
        if parameters:
            default_params.update(parameters)
        super().__init__(default_params)

    def generate_signals(self, data: pd.DataFrame) -> pd.Series:
        """
        Generate trading signals based on Moving Average Crossover
        Returns:
            1: Buy signal
            -1: Sell signal
            0: Hold/No position
        """
        short_ma = data['Close'].rolling(window=self.parameters['short_window']).mean()
        long_ma = data['Close'].rolling(window=self.parameters['long_window']).mean()
        
        signals = pd.Series(0, index=data.index)
        
        # Generate buy signal when short MA crosses above long MA
        signals[short_ma > long_ma] = 1
        
        # Generate sell signal when short MA crosses below long MA
        signals[short_ma < long_ma] = -1
        
        return signals 